﻿using Candy.Model;
using Candy.Web.Data;
using GalaSoft.MvvmLight.Command;
using System;

namespace Candy.ViewModel
{
    public class MembershipRequestViewModel : EntityViewModelBase<MembershipRequestDto>
    {

        private RelayCommand _accept;
        public RelayCommand Accept
        {
            get
            {
                return _accept ?? (_accept = new RelayCommand(ExecAcceptRequest, CanAcceptRequest));
            }
        }


        IDataService _dataService;
        public MembershipRequestViewModel(IDataService dataService, MembershipRequestDto dto) : base(dto)
        {
            _dataService = dataService;
        }


        /// <summary>
        /// Checks whether the AcceptRequest command is executable
        /// </summary>
        private bool CanAcceptRequest()
        {
            return true;
        }

        /// <summary>
        /// Executes the AcceptRequest command 
        /// </summary>
        private void ExecAcceptRequest()
        {
            _dataService.DataContext.GrantMembership(Entity, op =>
                {

                },null);
        }


        private RelayCommand _reject;
        public RelayCommand Reject
        {
            get
            {
                return _reject ?? (_reject = new RelayCommand(ExecReject, CanReject));
            }
        }

        /// <summary>
        /// Checks whether the Reject command is executable
        /// </summary>
        private bool CanReject()
        {
            return true;
        }

        /// <summary>
        /// Executes the Reject command 
        /// </summary>
        private void ExecReject()
        {
            throw new NotImplementedException();
        }


    }
}
